
#作业2 装饰器

import time
#定义装饰器的函数
def metric(fn):
    start_time = time.time()
    end_time = time.time()

    print('耗时：{:.4f}s'.format(end_time - start_time))
    return fn
#添加装饰器
@metric
class Student(object):
    def __init__(self,score):
        self.__score=score
    @property
    def score(self):
        return self.__score
    @score.setter
    def score(self,value):
        if not isinstance(value,int):
            raise ValueError('score must be an integer')
        if value<0 or value>100:
            raise ValueError('score must between 0~100')
        self.__score=value

stu2=Student(67)

stu2.score=28
print(stu2.score)





